package com.itheima.health.service.impl;


import com.itheima.health.common.yuyueShezhi;
import com.itheima.health.mapper.yuyueShezhiMapper;
import com.itheima.health.model.pojos.OrderSetting;

import com.itheima.health.service.YuyueShezhiService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Service
public class YuyueShezhiServiceImpl implements YuyueShezhiService {
    @Autowired
    private yuyueShezhiMapper yuyueShezhiMapper;

    @Override
    public List<yuyueShezhi> getOrderSettingByMonth(String month) {
        String modifiedDateStr = month + "-1";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d");
        LocalDate startTime = LocalDate.parse(modifiedDateStr, formatter);
        LocalDate endTime = startTime.plusMonths(1).minusDays(1);
        List<yuyueShezhi> list = yuyueShezhiMapper.selectOrderSetting(startTime, endTime);
        for (yuyueShezhi vo : list) {
            vo.setDate(vo.getDate().substring(8, 10));
            if (vo.getDate().charAt(0) == '0') {
                vo.setDate(vo.getDate().substring(1, 2));
            }
        }
        return list;
    }

   // @Override
   /* public void importOrderSettings(MultipartFile file) throws IOException {

        BufferedReader EasyExcel = null;
        List<OrderSetting> orderSettings = EasyExcel.read()
                .head(OrderSetting.class)
                .sheet()
                .doReadSync();
        yuyueShezhiMapper.saveAll(orderSettings);
    }*/


    }







